package com.ruoyi.ihome.service.impl;

import java.util.List;

import com.ruoyi.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ihome.mapper.FacilityMapper;
import com.ruoyi.ihome.domain.Facility;
import com.ruoyi.ihome.service.IFacilityService;

/**
 * 房间设施表Service业务层处理
 * 
 * @author mage
 * @date 2024-08-14
 */
@Service
public class FacilityServiceImpl implements IFacilityService 
{
    @Autowired
    private FacilityMapper facilityMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询房间设施表
     * 
     * @param facilityId 房间设施表主键
     * @return 房间设施表
     */
    @Override
    public Facility selectFacilityByFacilityId(Long facilityId)
    {
        return facilityMapper.selectFacilityByFacilityId(facilityId);
    }

    /**
     * 查询房间设施表列表
     * 
     * @param facility 房间设施表
     * @return 房间设施表
     */
    @Override
    public List<Facility> selectFacilityList(Facility facility)
    {
        // 带条件查询
        if(facility != null)
            return facilityMapper.selectFacilityList(facility);
        // 不带条件查询全部
        List<Facility> list = (List<Facility>) redisCache.getCacheObject("selectFacilityList");
        if(list == null){
            list = facilityMapper.selectFacilityList(facility);
            redisCache.setCacheObject("selectFacilityList",list);
        }
        return list;
    }

    /**
     * 新增房间设施表
     * 
     * @param facility 房间设施表
     * @return 结果
     */
    @Override
    public int insertFacility(Facility facility)
    {
        return facilityMapper.insertFacility(facility);
    }

    /**
     * 修改房间设施表
     * 
     * @param facility 房间设施表
     * @return 结果
     */
    @Override
    public int updateFacility(Facility facility)
    {
        return facilityMapper.updateFacility(facility);
    }

    /**
     * 批量删除房间设施表
     * 
     * @param facilityIds 需要删除的房间设施表主键
     * @return 结果
     */
    @Override
    public int deleteFacilityByFacilityIds(Long[] facilityIds)
    {
        return facilityMapper.deleteFacilityByFacilityIds(facilityIds);
    }

    /**
     * 删除房间设施表信息
     * 
     * @param facilityId 房间设施表主键
     * @return 结果
     */
    @Override
    public int deleteFacilityByFacilityId(Long facilityId)
    {
        return facilityMapper.deleteFacilityByFacilityId(facilityId);
    }
}
